﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FreesenseSubAIS.Core
{
    public class ReadIni
    {
        public static List<string> Read(string path)
        {
            List<string> lst = null;
            try
            {
                if (!File.Exists(path))
                    throw new Exception(string.Format("未找到指定文件:{0}", path));
                lst = new List<string>();
                using (StreamReader sr = new StreamReader(path))
                {
                    while (sr.Peek() > -1)
                    {
                        string s = sr.ReadLine().Trim();
                        if (string.IsNullOrEmpty(s) || s.StartsWith("#"))
                            continue;
                        lst.Add(s);
                    }
                }
            }
            catch (Exception ex)
            {
                if (lst != null)
                {
                    lst.Clear();
                    lst = null;
                }
                throw ex;
            }
            return lst;
        }
    }
    public class CalcConfigs
    {
        public int Type { set; get; }
        public string Name { set; get; }

        public override string ToString()
        {
            return string.Format("{0}-{1}", Type, Name);
        }
    }
}
